<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('条形码列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <p>搜集时间：</p>
                            <input type="text" class="time-input datetime" data-type="datetime"
                                   data-format="yyyy-MM-dd HH:mm:ss" id="startTime1" placeholder="开始时间"
                                   name="params[beginDepartdate]"/>
                            <span>-</span>
                            <input type="text" class="time-input datetime" data-type="datetime"
                                   data-format="yyyy-MM-dd HH:mm:ss" id="endTime1" placeholder="结束时间"
                                   name="params[endDepartdate]"/>
                        </li>

                        <li class="select-time">
                            <p>暂存时间：</p>
                            <input type="text" class="time-input datetime" data-type="datetime"
                                   data-format="yyyy-MM-dd HH:mm:ss" id="startTime3" placeholder="开始时间"
                                   name="params[beginHolddate]"/>
                            <span>-</span>
                            <input type="text" class="time-input datetime" data-type="datetime"
                                   data-format="yyyy-MM-dd HH:mm:ss" id="endTime3" placeholder="结束时间"
                                   name="params[endHolddate]"/>
                        </li>
                        <li class="select-time">
                            <p>出库时间：</p>
                            <input type="text" class="time-input datetime" data-type="datetime"
                                   data-format="yyyy-MM-dd HH:mm:ss" id="startTime4" placeholder="开始时间"
                                   name="params[beginCardate]"/>
                            <span>-</span>
                            <input type="text" class="time-input datetime" data-type="datetime"
                                   data-format="yyyy-MM-dd HH:mm:ss" id="endTime4" placeholder="结束时间"
                                   name="params[endCardate]"/>
                        </li>

                        <!--<li class="select-time">-->
                        <!--<p>上传时间：</p>-->
                        <!--<input type="text" class="time-input datetime" data-type="datetime"-->
                        <!--data-format="yyyy-MM-dd HH:mm:ss" id="startTime2" placeholder="开始时间"-->
                        <!--name="params[beginUploaddate]"/>-->
                        <!--<span>-</span>-->
                        <!--<input type="text" class="time-input datetime" data-type="datetime"-->
                        <!--data-format="yyyy-MM-dd HH:mm:ss" id="endTime2" placeholder="结束时间"-->
                        <!--name="params[endUploaddate]"/>-->
                        <!--</li>-->
                        <li>
                            <p>来源科室：</p>
                            <select name="sourceoffice" th:with="v=${dep}">
                                <option value="">所有</option>
                                <option th:each="u : ${v}" th:text="${u.departname}"
                                        th:value="${u.departid}"></option>
                            </select>
                        </li>
                        <li>
                            <p>废物类别：</p>
                            <select name="trashtype" th:with="v=${trash}">
                                <option value="">所有</option>
                                <option th:each="u : ${v}" th:text="${u.trashname}"
                                        th:value="${u.trashid}"></option>
                            </select>
                        </li>
                        <li>
                            <p>重量：</p>
                            <input type="number" name="trashweight"/>
                        </li>
                        <li>
                            <p>卫生员：</p>
                            <select type="text" name="healthper" th:with="v=${user}">
                                <option value="">所有</option>
                                <option th:each="u : ${v}" th:text="${u.username}"
                                        th:value="${u.userid}"></option>
                            </select>

                        </li>
                        <li>
                            <p>暂存员：</p>
                            <select type="text" name="tempper" th:with="v=${user}">
                                <option value="">所有</option>
                                <option th:each="u : ${v}" th:text="${u.username}"
                                        th:value="${u.userid}"></option>
                            </select>
                        </li>
                        <li>
                            <p>出库员：</p>
                            <select type="text" name="cardid" th:with="v=${user}">
                                <option value="">所有</option>
                                <option th:each="u : ${v}" th:text="${u.username}"
                                        th:value="${u.userid}"></option>
                            </select>
                        </li>
                        <!--<li>-->
                        <!--<p>医料桶编号：</p>-->
                        <!--<input type="text" name="bucketcode"/>-->
                        <!--</li>-->
                        <li>
                            <p>医废停滞：</p>
                            <select type="text" name="bcstatis" th:with="type=${@dict.getType('yf_position_location')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <!--<li>-->
                        <!--<p>运输：</p>-->
                        <!--<input type="text" name="cardid"/>-->
                        <!--</li>-->

                        <li>
                            <p>预警状态：</p>
                            <select name="tagsign" th:with="type=${@dict.getType('yf_notice')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <!--<li class="select-time">-->
                        <!--<p>报表提交时间：</p>-->
                        <!--<input type="text" class="time-input datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"  id="startTime5" placeholder="开始时间" name="params[beginBbdate]"/>-->
                        <!--<span>-</span>-->
                        <!--<input type="text" class="time-input datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"  id="endTime5" placeholder="结束时间" name="params[endBbdate]"/>-->
                        <!--</li>-->
                        <li>
                            <p>异常状态：</p>
                            <select name="ycstatis" th:with="type=${@dict.getType('yf_stranded')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <!--<li class="select-time">-->
                        <!--<p>null：</p>-->
                        <!--<input type="text" class="time-input datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"  id="startTime6" placeholder="开始时间" name="params[beginYcdate]"/>-->
                        <!--<span>-</span>-->
                        <!--<input type="text" class="time-input datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"  id="endTime6" placeholder="结束时间" name="params[endYcdate]"/>-->
                        <!--</li>-->
                        <li>
                            <p>更新：</p>
                            <select name="update" th:with="type=${@dict.getType('yf_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="yf:tagmanager:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="yf:tagmanager:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="yf:tagmanager:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="yf:tagmanager:dianziliandan:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>


    </div>

</div>
<div class="modal inmodal fade" id="myModal6" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <canvas></canvas>
    </div>
</div>

<th:block th:include="include :: footer"/>
<!--<script th:src="@{/js/jquery-barcode.js}"></script>-->
<script th:src="@{/js/JsBarcode.all.min.js}"></script>
<script th:inline="javascript">
    //查看条码权限
    var bcode = [[${@permission.hasPermi('yf:department:bCode')}]]
    //查看照片权限
    var photoView = [[${@permission.hasPermi('yf:department:photoView')}]]

    var editFlag = [[${@permission.hasPermi('yf:tagmanager:edit')}]];
    var removeFlag = [[${@permission.hasPermi('yf:tagmanager:remove')}]];
    //更新状态
    var sta = [[${@dict.getType('yf_status')}]];
    //异常
    var yc = [[${@dict.getType('yf_stranded')}]];
    //通知
    var notice = [[${@dict.getType('yf_notice')}]];
    //科室
    var dep = [[${dep}]]
    //分类
    var trash = [[${trash}]]
    //用户
    var user = [[${user}]]

    var prefix = ctx + "yf/tagmanager";

    //生成条形码
    function bCodes(qid) {
        $("#myModal6>div").html(" <canvas></canvas>");
        JsBarcode("#myModal6>div>canvas", qid, {
            format: "CODE128",
            height: 150,
            width: 5,
            textAlign: "center",
            textPosition: "button",
            font: "serif",
            fontOptions: "bold",
            fontSize: 40,
            textMargin: 5,
            marginTop: 20,
            marginLeft: 20,
            marginRight: 20,
            marginBottom: 20
        });
    }

    function photo_View(qid) {
        console.log("查看照片：", qid)
    }


    $(function () {
        var options = {
            url: prefix + "/list",
            search: false,
            showSearch: true,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            pageSize: 50,
            pageList: [100, 300, 500, 700, 1000],
            height: $(window).height() - 180,
            modalName: "条形码",
            showToggle: false,
            sortName: "departdate",
            sortOrder: "desc",
            columns: [
                {
                    field: 'codeid',
                    title: 'SSID',
                    align: 'center',
                    sortable: true
                },
                {
                    field: 'departdate',
                    align: 'center',
                    title: '搜集时间',
                    sortable: true
                },
                {
                    field: 'holddate',
                    align: 'center',
                    title: '入库时间',
                    sortable: true
                },
                {
                    field: 'cardate',
                    align: 'center',
                    title: '出库时间',
                    sortable: true
                },
                {
                    field: 'sourceoffice',
                    align: 'center',
                    sortable: true,
                    title: '来源科室',
                    formatter: function (value, item, index) {
                        return $.table.selectListLabel(dep, item.sourceoffice, "departid", "departname");
                    }
                },
                {
                    field: 'trashtype',
                    align: 'center',
                    title: '废物类别',
                    formatter: function (value, item, index) {
                        return $.table.selectListLabel(trash, item.trashtype, "trashid", "trashname");
                    }
                },
                {
                    field: 'trashweight',
                    align: 'center',
                    sortable: true,
                    title: '重量（kg）'
                },
                {
                    field: 'healthper',
                    align: 'center',
                    title: '卫生员',
                    formatter: function (value, item, index) {
                        return $.table.selectListLabel(user, item.healthper, "userid", "username");
                    }
                },
                {
                    field: 'tempper',
                    align: 'center',
                    sortable: true,
                    title: '暂存员',
                    formatter: function (value, item, index) {
                        return $.table.selectListLabel(user, item.tempper, "userid", "username");
                    }
                },


                {
                    field: 'cardid',
                    title: '出库员',
                    sortable: true,
                    align: 'center',
                    formatter: function (value, item, index) {
                        return $.table.selectListLabel(user, item.cardid, "userid", "username");
                    }
                },
                {
                    field: 'bucketcode',
                    align: 'center',
                    title: '医料桶编号',
                    visible: false,
                },
                {
                    field: 'ycstatis',
                    align: 'center',
                    title: '异常状态',
                    formatter: function (value, item, index) {
                        var str = item.departdate.replace(/-/g, '/');
                        var old = new Date(str);
                        var date = new Date();

                        if ((date.getTime() - old.getTime()) > (86400000 * 2))
                            return $.table.selectDictLabel(yc, item.ycstatis);
                        else
                            return $.table.selectDictLabel(yc, 2);
                    }
                }, {
                    field: 'tagsign',
                    align: 'center',
                    title: '通知',
                    formatter: function (value, item, index) {
                        return $.table.selectDictLabel(notice, item.tagsign);
                    }
                },
                {
                    field: 'update',
                    align: 'center',
                    title: '是否更新',
                    formatter: function (value, item, index) {
                        return $.table.selectDictLabel(sta, item.update);
                    }
                },
                {
                    field: 'upstatus',
                    align: 'center',
                    title: '上送状态',
                    visible: false,
                    formatter: function (value, item, index) {
                        return $.table.selectDictLabel(sta, item.upstatus);
                    }
                },


                // {
                //     field: 'bcstatis',
                //     title: '01,02,03,04'
                // },
                // {
                //     field: 'tagsign',
                //     title: '预警短信发送信息1发送，0未发送'
                // },
                // {
                //     field: 'bbdate',
                //     title: '报表提交时间'
                // },
                // {
                //     field: 'ycstatis',
                //     title: '异常记录状态'
                // },
                // {
                //     field: 'yccontent',
                //     title: '异常记录处理内容'
                // },
                // {
                //     field: 'ycdate',
                //     title: 'null'
                // },
                // {
                //     field: 'zfstatus',
                //     title: 'null'
                // },
                // {
                //     field: 'zfcontent',
                //     title: '图片'
                // },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.codeid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.codeid + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + photoView + '" href="javascript:void(0)" onclick="photo_View(\'' + row.codeid + '\')"><i class="fa fa-picture-o"></i>照片</a> ');
                        actions.push('<button type="button" class="btn btn-info btn-xs ' + bcode + '"  data-toggle="modal" data-target="#myModal6" onclick="bCodes(\'' + row.codeid + '\');"><i class="fa fa-barcode"></i>条形码</button> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>